package com.xinnet.mms.notice.service.impl;

import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xinnet.core.utils.page.PageView;
import com.xinnet.mms.entity.Notice;
import com.xinnet.mms.notice.dao.NoticeDao;
import com.xinnet.mms.notice.service.NoticeService;

@Service("noticeService")
public class NoticeServiceImpl implements NoticeService {

	@Autowired
	private NoticeDao noticeDao;
	
	/**添加一条消息数据进公告表*/
	@Override
	public void addMessage(Notice notice) throws SQLException {
		noticeDao.addMessage(notice);
	}

	/**查询消息记录*/
	@Override
	public PageView<Notice> queryMessage(PageView<Notice> pageView) throws SQLException {
		pageView=noticeDao.queryMessage(pageView);
		if(pageView.getRecords().isEmpty())
			return null;
		return pageView;
	}

	/**通过ID获取消息详情*/
	@Override
	public Notice getMessageById(String id) throws SQLException {
		return noticeDao.getMessageById(id);
	}

	/**通过ID修改消息内容*/
	@Override
	public void updateMessageById(Notice notice) throws SQLException {
		noticeDao.updateMessageById(notice);
	}

	/**通过ID删除消息*/
	@Override
	public void delMessageById(String id) throws SQLException {
		noticeDao.delMessageById(id);
	}

	/**标题名模糊查询消息*/
	@Override
	public PageView<Notice> queryMsgByTitle(PageView<Notice> pageView,Notice notice) throws SQLException {
		pageView=noticeDao.queryMsgByTitle(pageView, notice);
		if(pageView.getRecords().isEmpty())
			return null;
		return pageView;
	}

	/**获取政策公告列表*/
	@Override
	public PageView<Notice> queryPolicy(PageView<Notice> pageView) throws SQLException {
		pageView=noticeDao.queryPolicy(pageView);
		if(pageView.getRecords().isEmpty())
			return null;
		return pageView;
	}

	/**带查询条件获取政策公告列表*/
	@Override
	public PageView<Notice> queryPolicy(PageView<Notice> pageView, Notice notice) throws SQLException {
		pageView=noticeDao.queryPolicy(pageView,notice);
		if(pageView.getRecords().isEmpty())
			return null;
		return pageView;
	}

	/**通过ID获取公告详情*/
	@Override
	public Notice getPolicyById(String id) throws SQLException {
		return noticeDao.getPolicyById(id);
	}

	/**通过ID删除公告*/
	@Override
	public void delPolicyById(String id) throws SQLException {
		noticeDao.delPolicyById(id);
	}

	/**修改公告*/
	@Override
	public void updatePolicyById(Notice notice) throws SQLException {
		noticeDao.updatePolicyById(notice);
	}

	/**添加公告*/
	@Override
	public void addPolicy(Notice notice) throws SQLException {
		noticeDao.addPolicy(notice);
	}

	/**查询六条政策公告*/
	@Override
	public List<Notice> getPolicyInMain() throws SQLException {
		return noticeDao.getPolicyInMain();
	}

	/**查询六条动态消息*/
	@Override
	public List<Notice> getMsgInMain() throws SQLException {
		return noticeDao.getMsgInMain();
	}

}
